<template>
  <div>
    <!-- 表格 -->
    <el-table :data="tableData" border stripe fit>
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column
        v-for="(item, index) in columnList"
        :key="index"
        :label="item.label"
        :prop="item.value"
        :min-width="item.minWidth"
      ></el-table-column>
    </el-table>

    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="queryInfo.pageNum"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="queryInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      columnList: [
        { label: '姓名', value: 'name', minWidth: '100' },
        { label: '姓名', value: 'name', minWidth: '100' }
      ],
      tableData: [],
      queryInfo: {
        pageNum: 1,
        pageSize: 10
      },
      total: 0
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取数据
    getList() {},
    // 分页
    // 监听 pageSize 改变的事件
    handleSizeChange(newPageSize) {
      this.queryInfo.pageSize = newPageSize
      this.getList()
    },
    // 监听 当前页码值 改变的事件
    handleCurrentChange(newCurrentPage) {
      this.queryInfo.pageNum = newCurrentPage
      this.getList()
    }
  }
}
</script>

<style lang="scss" scoped></style>
